<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<#include "lib/lib.html" />
<title>添加应用</title>
</head>
<body>
<div class="pd-20">
	<form action="${basePath}/admin/addapp.do" method="post" class="form form-horizontal" id="form-app-add">
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>应用名称：</label>
			<div class="formControls col-5">
				<input type="text" class="input-text" value="" placeholder="" id="appName" name="appName" datatype="*2-60" nullmsg="应用名称不能为空">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-3">应用类型：</label>
			<div class="formControls col-5"> <span class="select-box" style="width:150px;">
				<select class="select" name="appType" size="1">
					<option value="1">客户端</option>
					<option value="2">P C端</option>
					<option value="3">其他</option>
				</select>
				</span> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>应用编码：</label>
			<div class="formControls col-5">
				<input type="text" placeholder="" autocomplete="off" class="input-text" errormsg="请输入应用编码！" datatype="*2-60"   id="appKey" name="appKey">
			</div>
			<div class="col-4"> </div>
		</div>
		<dl class="row cl">
		<!-- 上传SDK包 -->
		<label class="form-label col-3">应用logo：</label>
				<div class="formControls col-5">
					<input type="text" dataType="*" name="app_logo" class="dd_input uploadPackgeMd5 width200" readonly="readonly" nullMsg="请上传ZIP文件" id="sdkDocumentUrl" />
					<input type="file" name="file" class="installUploadPackge width150 fileInputClass" class="upload-btn" id="sdkDocumentUrlFile" />
				</div>
			</dl>	
		<div class="row cl">
			<label class="form-label col-3">应用描述：</label>
			<div class="formControls col-5">
				<textarea name="appDesc" cols="" rows="" class="textarea"  placeholder="说点什么...128个字符以内" dragonfly="true" datatype="*1-128" onKeyUp="textarealength(this,128)"></textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/128</p>
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</div>
<script type="text/javascript" src="${basePath}/public/js/jquery.myhtml5upload.js"></script>
<script type="text/javascript">
$(function(){
	$("#form-app-add").Validform({
		tiptype:2,
		ajaxPost:true,
		callback:function(data){
			$.Hidemsg()
			if(data.resultCode==200){
				layer.msg('保存成功!', {
					icon : 1,
					time : 1000
				});
				parent.location.replace("${basePath}/admin/goapplist.do");
				layer_close();
			}else{
				$("#form-app-add").resetForm();
				layer.msg('保存失败，请你检查数据!', {
					icon : 1,
					time : 1000
				});
			}
		}
	});
});
	
	$("input.installUploadPackge").h5upload({
		//上传的格式
		'fileTypeExts': '',
		'fileObjName': 'file',
		//上传处理程序
		'url': '${basePath}/upload/addFiles.do',
		//上传文件的大小限制
		'fileSizeLimit': 50000 * 1024 * 1024,
		//上传到服务器，服务器返回相应信息到data里
		'onUploadSuccess': function(file, data) {
			var result = JSON.parse(data);
			if(!!result && result.resultCode == 200) {
				var data = result.Data;
				$("#sdkDocumentUrl").val(data.url);
				$("#sdkDocumentName").val(data.fileName);
			} else {
				alert(result.message);
			}
		},
		//上传失败
		'onUploadError': function(file) {
			alert("上传失败!");
		}
	});
</script>
</body>
</html>